import time

from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

# 1.创建驱动对象
service = Service("C:/Program Files/Google/Chrome/Application/chromedriver.exe")
driver = webdriver.Chrome(service=service)

# 2.打开浏览器
driver.get("file:///C:/Users/82073/Desktop/pagetest/%E6%B3%A8%E5%86%8CA.html")


select = Select(driver.find_element(By.CSS_SELECTOR, "#selectA"))
select.select_by_index(2)
time.sleep(1)
select.select_by_index(1)
time.sleep(1)
select.select_by_index(0)
select.select_by_value()
select.select_by_visible_text()
# driver.find_element(By.CSS_SELECTOR, "select[id='selectA'] option[value='gz']").click()
# time.sleep(3)
# driver.find_element(By.CSS_SELECTOR, "select[id='selectA'] option[value='sh']").click()
# time.sleep(3)
# driver.find_element(By.CSS_SELECTOR, "select[id='selectA'] option[value='bj']").click()

# 4.3s后关闭
time.sleep(3)

# 5.关闭驱动对象
driver.close()